package com.google.code.solrdimension.core.dimensions;

import java.util.List;

/**
 * Dimension holds the info necessary to display the "Facet" and "Facet Values"
 * @author mhc
 *
 */
public class Dimension implements Comparable<Dimension>{
    
    private String displayName;
    
    private List<DimensionValue> dimensionValues;
    
    private long totalValueCount;
    
    public long getTotalValueCount() {
        return totalValueCount;
    }

    /**
     * THIS IS THE TOTAL FACET VALUE COUNT, NOT THE TOTAL RECORD COUNTS, THERE IS A HUGE DIFFERENCE
     * @param totalValueCount
     */
    public void setTotalValueCount(long totalValueCount) {
        this.totalValueCount = totalValueCount;
    }

    public Dimension(String displayName, long totalValueCount){
        this.displayName = displayName;
        this.totalValueCount = totalValueCount;
        
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public List<DimensionValue> getDimensionValues() {
        return dimensionValues;
    }

    public void setDimensionValues(List<DimensionValue> dimensionValues) {
        this.dimensionValues = dimensionValues;
    }
    
    @Override
    public String toString(){
        
        StringBuffer result = new StringBuffer();
     
        if (dimensionValues != null && !dimensionValues.isEmpty()){
            
            result.append("\nDimension: ").append(displayName).append("(").append(totalValueCount).append(") \n");
            result.append(" -------DIMENSION VALUES: -------- \n");
            
            
            for (DimensionValue dimensionValue : dimensionValues){
                
                result.append("DimenaionValue displayName: ").append(dimensionValue.getDisplayName()).append("\n");
                result.append("DimenaionValue count: ").append(dimensionValue.getCount()).append("\n");
                result.append("DimenaionValue filterQuery: ").append(dimensionValue.getFilterQuery()).append("\n");
                result.append("DimensionValue facetPrefixQuery: ").append(dimensionValue.getFacetPrefixQuery()).append("\n");
                result.append(" --------------- \n");
            }
            
        }
        
        return result.toString();
    }

    public int compareTo(Dimension paramT) {
        // TODO Auto-generated method stub
        return 0;
    }

}
